package com.api.shopapi.mapper;

import com.api.shopapi.entity.NursingLevelPrice;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author maochuan
 */
@Repository
@Mapper
public interface NursingLevelPriceMapper {
    @Insert("insert into nursing_level_price " +
            "(NursingLevelPriceCode,nursingLevelCode,Price,CalculationType) " +
            "value (#{nursingLevelPrice.NursingLevelPriceCode},#{nursingLevelPrice.NursingLevelCode},#{nursingLevelPrice.Price}," +
            "#{nursingLevelPrice.CalculationType})")
    int insert(@Param("nursingLevelPrice") NursingLevelPrice nursingLevelPrice);

    @Update("update nursing_level_price set nursingLevelCode = #{nursingLevelPrice.NursingLevelCode},Price = #{nursingLevelPrice.Price}," +
            "CalculationType=#{nursingLevelPrice.CalculationType} " +
            "where nursingLevelPriceCode=#{nursingLevelPrice.NursingLevelPriceCode}")
    int updateByNursingLevelPriceCode(@Param("nursingLevelPrice") NursingLevelPrice nursingLevelPrice);

    @Select("select * from nursing_level_price where NursingLevelCode=#{nursingLevelCode} and CalculationType=#{calculationType} limit 1")
    NursingLevelPrice getByNursingLevelCodeAndCalculationType(@Param("nursingLevelCode") String nursingLevelCode,@Param("calculationType") String calculationType);

    @Select("select * from nursing_level_price where NursingLevelCode = #{nursingLevelCode} order by Price")
    List<NursingLevelPrice> getListAllByNursingLevelCode(@Param("nursingLevelCode") String nursingLevelCode);

    @Select("select * from nursing_level_price where nursingLevelPriceCode = #{nursingLevelPriceCode} limit 1")
    NursingLevelPrice getByNursingLevelPriceCode(@Param("nursingLevelPriceCode") String nursingLevelPriceCode);
}
